package com.cjx.api.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cjx.api.mapper.UserInterfaceInvokeMapper;
import com.cjx.api.model.dto.userinterfaceinvoke.UserInterfaceInvokeAddRequest;
import com.cjx.api.model.entity.UserInterfaceInvoke;
import com.cjx.api.service.UserInterfaceInvokeService;
import org.aspectj.weaver.ast.Var;
import org.springframework.stereotype.Service;

/**
* @author cjx
* @description 针对表【user_interface_invoke(用户用户接口调用调用表)】的数据库操作Service实现
* @createDate 2024-05-08 10:50:21
*/
@Service
public class UserInterfaceInvokeServiceImpl extends ServiceImpl<UserInterfaceInvokeMapper, UserInterfaceInvoke>
    implements UserInterfaceInvokeService {

    @Override
    public boolean invokeResultInUpdate(Long id) {
        return update(new LambdaUpdateWrapper<UserInterfaceInvoke>()
                .eq(UserInterfaceInvoke::getId, id)
                .setSql("totalInvokes = totalInvokes + 1"));
    }

    @Override
    public boolean addUserInterfaceInvoke(UserInterfaceInvokeAddRequest addRequest) {
        return save(BeanUtil.copyProperties(addRequest, UserInterfaceInvoke.class));
    }
}




